<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="./vuev2.5.21.js"></script>
  <style>
    .box{
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background-color: red;
    }
  </style>
</head>
<body>
    <div id="app">
        <input type="button" value="button" @click="flag=!flag">
        <transition 
          @before-enter="beforeEnte"
          @enter="enter"
          @after-enter="alertEnter">
            <div class="box" v-show="flag"></div>
        </transition>
    </div>
    <script>
        new Vue({
          el:"#app",
          data:{
            flag:false
          },
          methods:{
            beforeEnte(el){
              el.style.transform="translate(0,0)"
            },
            enter(el,done){
              el.offsetWidth//会强制刷新动画
              el.style.transform="translate(300px,300px)"
              el.style.transition="all 0.8s ease"
              done()
            },
            alertEnter(el){
              console.log('====================================');
              console.log(this.flag);
              console.log('====================================');
              this.flag = !this.flag
            }
          }
        })
    </script>
</body>
</html>